As a bicycler I used to travel on cycle daily for about half an hour to maintain fitness of my legs and body. But I want to know how much time and distance is needed for a good exercise.
As individual speeds vary depending on fitness, bike and conditions, most information on this subject discusses intensity and time spend exercising, rather than distance. Most leisure cyclists ride between 10-18mph (16-30kph) on the road, a bit less off-road. As you can see it's a fairly wide range, so time and intensity are better measures.They can also more easily be applied to other sports.
For good health, the WHO recommends:
Adults aged 18–64 should do at least 150 minutes of moderate-intensity aerobic physical activity throughout the week or do at least 75 minutes of vigorous-intensity aerobic physical activity throughout the week.
If you'd like to improve your cycling fitness as well as your health, then British Cycling has a number of beginners training plans, depending on what you would like to achieve.
However, not everyone responds the same way to exercise, so the improvements are not guaranteed.
There is no real answer to this, as it totally depends on what you mean by 'good exercise'.
For a professional racing cyclist it means 30 hours a week of structured training including effort above an below that required for an actual race.
For adults the American Heart Association recommends as a minimum:
at least 150 minutes per week of moderate-intensity aerobic activity or 75 minutes per week of vigorous aerobic activity, or a combination of both,
How many km and at what level of effort you can ride depends on your current level of fitness. Work up to a level that is sustainable and enjoyable for you.
I have no hard data to answer this, just my experience: I commute every day, 13 km one way, practically flat, and I do my best to do the route in 30-35 minutes with a city bike.
My legs are pretty toned, and when I have to step up on the travelled distance it's not a big deal.
But a more precise answer strongly depends on the single individual.
The distance covered is only one measure of your trip. The efforts and rewards of an exercise session will be related to both the length and the intensity.
Your 30 minutes could be 5 km at a casual dawdle, or 20 km at a hard pace.
Slower sustained riding builds the "slow twitch" fibres which can fire repeatedly for long times but aren't that strong. These are "endurance" muscles and help you ride for a long time.
Short, High intensity efforts build the "fast twitch" fibres, which are the "sprint" muscles. These get tired real quick and once that happens you have to slow down.
Riders with high endurance can ride all day at a moderate pace. Riders with fast twitch muscles can burst into fast sprints but may not have as much endurance. Ideally you want both.
Relevance? You need to mix it up - for example: From a red traffic light, go hard in a bigger gear than normal, right up to your fastest speed for as long as you can, then relax.
See if you can vary your route to get in a hill or slope to climb. Move your position on the bike a little, to recruit and train other muscles - you'll feel this.