Kanji are originally Chinese characters that the Japanese borrowed and adapted in order to write their own language. When the Japanese borrowed these characters, they used them in two ways: 1) they gave them the pronunciation of native Japanese words, giving rise to Kun'yomi (訓読み・くんよみ); and 2) they tried to approximate the original Chinese pronunciation using Japanese sounds for words that were borrowed from Chinese along with the characters, giving rise to On'yomi (音読み・おんよみ).
For example, 安 has Kun'yomi やす (as in 安い), meaning inexpensive, and 心 has Kun'yomi こころ, meaning heart. But you can join them to form the word 安心, pronounced あんしん (anshin), which uses the On'yomi of both Kanji (安：あん、心：しん). Compare this to Chinese 安心 (anxin, where "x" has a pronunciation similar to "sh").
I like to compare On'yomi and Chinese derived words with Latin derived words and roots in English. The English borrowed many Latin words and also used Latin semantic roots to build new words. Similarly, Japanese borrowed the Chinese writing system and many words, and then used the characters/Kanji in the same way we would use semantic roots in Western languages to build new words, usually using the On'yomi pronunciation of the kanji involved.
Here is an online article that explains this in greater detail and has some nice examples.
Hope this helps!