Can I book a flight from India to Latvia passing through Ukraine? Do I need a visa in Ukraine?
Unless you are going to leave the transit zone, no, you do not need a visa. The only required documents are travel passport and boarding pass (so bother to check-in in advance). This rule applies to all countries, not only India.
Here is the map of transit area in Boryspil:
Otherwise, you do need a visa if you plan to exit KBP airport, as India citizens are required a visa to enter Ukraine.
You can apply for visa either in your country of residence or directly in airport.
Citizens of many countries can enter Ukraine without a visa with just a passport alone, for periods of up to 90 days out of 180: USA, Canada, EU nations, United Kingdom, Switzerland, Japan, many countries of the former USSR. See complete list below. Note that a few "first-world countries," namely Australia and New Zealand, aren't included in the list; citizens of these countries must obtain visas even for short visits.