The 10 commandments are just the few that God Himself said directly to the entire Jewish nation on Mount Sinai. The remainder of the 613 was spoken to Moses in order to record and present to the Jewish nation. The Torah would have been given regardless of our sins in the desert.
Why were these particular commandments chosen to be spoken directly by God?
This has been addressed throughout the generations by many scholars.
Rashi in Shmos states that all 613 commandments are subsumed in the Ten Commandments. [Rashi 24:12]
Many attempt to demonstrate how the entire 613 mitzvos are actually subcategories of the 10 commandments. It is beyond the scope of this venue to enumerate the different approaches on how to categorize them.
I am unsure of how advanced you are in your Torah learning, but there is an interesting article written on the subject here: