Why does vaccine development take so long?
Roni Saiba's answer does a good job of explaining what goes into current vaccine development and why it takes so much effort, but I want to directly address the question of why we can't just grow some virus, kill it with UV and have a protective vaccine.
The answer is that not all immune responses to viral antigens are helpful in fighting infections of that virus. In some cases it can be harmful; antibodies to dengue virus of one serotype will attach to viral particles of another serotype but aren't able to inactivate them. The attachment of antibodies to active viruses makes their absorption by cells more efficient, and infections where this antibody-dependent enhancement occurs are more severe than first-time dengue infections.
Some viruses have evolved mechanisms to capitalize on this. The reason we need to get a new flu shot every year is that influenza viruses present a &quot;knob&quot; at the end of their glycoprotein that can change its structure and still retain function. This part is much more 'visible' to the immune system than parts of the virus that can't tolerate changes, so the immune response to this variable part outcompetes and prevents an immune response that would provide long-lasting protection. Conserved stalk-targeting vaccines are being intensely investigated for this reason. SARS-CoV-2 may have a immune-faking mechanism as well: the &quot;spike&quot; glycoproteins responsible for binding the ACE2 receptor and entering the cell convert to their post-binding form prematurely part of the time. Antibodies that bind the &quot;post-fusion&quot; form of the protein don't inactivate the virus, and this form sticks out more so may serve to compete for immune attention with the pre-fusion form that would provide protection if bound by antibodies.
In this last example, we can see that a vaccine made of killed SARS-CoV-2 virus particles would be useless if all of the spike proteins had converted to the post-fusion state. The mRNA vaccines therefore don't encode the natural spike protein, but a mutated version which can't convert to the post fusion state as easily:

S-2P is stabilized in its prefusion conformation by two consecutive proline substitutions at amino acid positions 986 and 987

In conclusion, viruses and the immune system are very complicated. Simple vaccines work for some viruses, and don't work for others. When they don't work, the reason is always different, but hopefully I've communicated some general understanding of the background issues.
EDITS:
This doesn't relate to the rest of my answer but I want to respond to Ilmari Karonen's and there is not enough room in a comment.
Looking at the timeline for SARS-CoV-2 vaccine development gives a very misleading impression of how long it takes generally. This is because ~90% of the development work was already done before COVID-19 was ever identified, in the 18 years since the SARS-CoV-1 outbreak started in 2002. Vaccines against SARS were developed and tested up to phase I trials, but couldn't proceed further since the virus was eliminated. I discussed this in a previous answer to a similar question, but to expand/reformat, here's some of what we knew and had available on March 17th 2020, when the &quot;covid vaccine timeline&quot; begins:

Identified the receptor as ACE2, and knew that antibodies targeting the receptor binding domain (RBD) of the spike protein neutralize the virus. Protocols to test that these were also true of SARS-CoV-2 were already developed and validated. Without this there would have been a lot more trial-and-error experimentation and false starts with vaccine candidates that looked promising but didn't pan out in testing.
Animal models. There is no naturally-occurring model organism for COVID-19. This is a subtle point because other animals can be infected with the virus, and some develop morbidities because of it. However, these are different enough from what we see in humans that something that protects against the reactions we see in the animal can't be assumed to protect against the reactions that cause problems in humans. For SARS, researchers developed transgenic mice that used the human version of ACE2, and showed that the disease they got from SARS were analogous to the disease humans got. This took several years, and the colony was still available when the virus causing the outbreak in Wuhan was identified as SARS-like and researchers started looking for animal models. As an aside, in an interview on This Week in Virology that I can't find right now, one of the maintainers of that colony said they were months or weeks away from shutting it down and euthanizing all the transgenic mice when the pandemic began, so if funding had been just a bit tighter we probably would not be having this particular conversation now.
How to stabilize the pre-fusion form of coronavirus spike proteins had been determined from work on SARS and MERS vaccines.

In addition to these, a large amount of miscellaneous knowledge about coronavirus functions and the immune reactions to them had been accumulated, and this sped up development, and increased confidence in results, which allows vaccine candidate production and testing to proceed more aggressively.
Historically, vaccine development has taken years or decades of research after the need has been identified. Testing is still longer in many cases, but the current case is very unusual.