Your database contains all of your content (pages, posts, comments, form-entries, etc.,) and settings (for themes, plugins, etc.,) in the form of a table. Any updated or deleted content and setting changes will stick around and add bloat to your database, slowing down your site.
From time to time, you need to purge deleted data and perform a general clean up of the database. If you know your way around PhpMyAdmin, you can perform the optimization via some SQL queries. Plugins like JetPack and WP Optimize also offer database optimization options.