A lot of it is trial and error. Some of it based on anecdotal... this plant likes that one, and these two don't get a long. Then there's planting to take advantage of the space requirements, and maturity times. For example: I always use my favorite radish (French Breakfast) as a row marker, ans sow it in the lettuce bed. When Radish is removed, that leaves more space for the lettuce. There's the 3 sisters that worked so well for native Americans. I've found that corn and potatoes make great bed mates. Strawberries and onions/garlic do well together, and strawberries can be allowed to send runners into the corn rows for natural progression to allow the strawberry bed to rotate through the garden. There are lots of charts if you are interested in pursuing more info.