Two Pokémon can produce offspring only when they share at least one Egg Group and are of opposite genders. A species can belong to two groups at once — then it breeds with both. Ditto is the exception: it is compatible with everything that can breed at all.
A separate question is how Pokémon evolve — with a stone, by trade, through friendship or at a specific time of day.
This answers the question “who with whom”. How the rest works — IV inheritance, Destiny Knot, Everstone passing down the Nature, Hidden Abilities and Egg Moves — is covered in the guide breeding step by step.
15 groups
1304 assignmentsThe total is higher than the number of species, because some belong to two groups at once. Only base forms are counted — Mega Evolutions and regional forms inherit their groups from the original form and would double the result.