How can I have authenticated WordPress users automatically sign into Moodle?

As far as the WordPress part is concerned, you’ll need to write a plugin which creates a widget or otherwise inserts a link onto your WordPress site. The following assumes you are familiar with plugin development.

Generate the link by using a wp_nonce_url to help ensure the WordPress user is the one who clicked the link.

See:
WordPress Nonces « WordPress Codex

When the user clicks the link, it should submit the appropriate user data needed. For example, if the user login is the same on both WordPress and moodle then you will want to get user_login.

See:
Function Reference/get userdata « WordPress Codex

It is possible to generate a url with a login authentication token. I’m not familiar with doing so via moodle API, and this is beyond the scope of this StackExchange network, so you’ll have to ask a specific question for that elsewhere.

That said, here is one general method example:
Passwordless authentication: Secure, simple, and fast to deploy ✩
Mozilla Hacks – the Web developer blog

Back to the WordPress related scripting. Make sure your plugin adds the moodle host in a allowed_redirect_hosts filter.

See:
Plugin API/Filter Reference/allowed redirect hosts « WordPress Codex

Your script should use a wp_safe_redirect at this point to redirect the WordPress user to the new login authentication url.

See:
Function Reference/wp safe redirect « WordPress Codex

Assuming you solve the moodle authentication issue, this should give you a general idea of what can be done to solve the WordPress side of the problem.

Update: There is an “external database authentication” plugin for moodle which seems ideal for this. Again, it’s beyond the scope of this site, but learn how to use it and you should be set.

This method uses an external database table to check whether a given
username and password is valid. If the user does not currently exist
in Moodle a new account will be created and their information copied
from the external database.

See:
External database authentication – MoodleDocs