It is an frequently occurring but incorrect assumption that the purpose of mining is creating bitcoins. The reason mining exists, is finding blocks, so that a global consensus about the order of valid transactions can be established. Mining is hard because we don't want too frequent blocks.
One of the very original ideas in Bitcoin is combining this block construction consensus mechanism with the initial introduction of new currency, but it could have been done in very different ways.
So, even when the block subsidy dwindles and eventually becomes zero, mining will continue. Blocks will still be needed and if miners don't create them, other miners will pop up. They are expected to be paid from transaction fees.