How to insert into a table daily automatically in postgresql?
PostgreSQL does not have a built in job scheduler.  There are many options to run jobs on a schedule.  If you already have a generic job scheduler in use in your IT environment, I'd recommend making use of that, rather than installing and configuring and learning a new one just for PostgreSQL.  For example, I use "cron" for all my job scheduling outside of PostgreSQL, so I use it for PostgreSQL as well, using something like psql -f job.sql as the command to run.  You will have to arrange for the job to be able to connect to the database without a password--there are several ways to do that depending on your security environment.

For the query itself, you can't expect the job to run at exactly midnight down to the nanosecond. So run the job several minutes after midnight (to make sure clock skew doesn't cause it to accidentally run before midnight), and put WHERE clauses in the query that uses a timestamp in the table to pull out the data exactly aligned to date boundaries.